<template>
  <div class="report-item-box" @click="onDetail">
    <div class="img-box" :style="{backgroundImage: 'url(' + data.coverUrl + ')'}">
      <div class="zhiwu"></div>
    </div>
    <div class="content-box">
      <div class="title">{{data.name}}</div>
      <div class="desc">{{data.desc}}</div>
      <div class="date">
        <img src="../../../assets/date2.png" class="icon" alt="">
        <span v-if="data.publishDate">{{formatDate(data.publishDate)}}</span>
        <span v-else>待定</span>
      </div>
      <div class="tags-box">
        <div class="tag" v-for="(item, index) of data.tags" :key="index">{{item.name}}</div>
      </div>
    </div>
  </div>
</template>

<script>
import moment from "moment";
moment.locale("zh-cn");
export default {
  props: {
    data: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  methods: {
    // 处理时间
    formatDate(date) {
      return moment(date).format("lll");
    },
    onDetail() {
      let routerJump = this.$router.resolve({ name: 'InstituteDetail', query: {uuid: this.data.uuid} });
      window.open(routerJump.href, '_blank');
    }
  }
}
</script>

<style lang="scss" scoped>
.report-item-box {
  height: 420px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  .img-box {
    width: 100%;
    height: 158px;
    background-size: cover;
    position: relative;
    .zhiwu {
      width: 100px;
      height: 74px;
      // background: url('../../../assets/logo_zhiwu.png') no-repeat;
      background-size: cover;
      position: absolute;
      top: 32px;
      left: 50%;
      margin-left: -50px;
    }
  }
  .content-box {
    padding: 20px 18px;
    background: #FFFFFF;
    .title {
      height: 48px;
      font-size: 18px;
      font-family: PingFangSC-Semibold, PingFang SC;
      font-weight: 600;
      color: #272727;
      line-height: 24px;
      margin-bottom: 8px;
    }
    .desc {
      height: 66px;
      font-size: 14px;
      font-weight: 400;
      color: #696969;
      line-height: 22px;
      margin-bottom: 16px;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 3;
      overflow: hidden;
      word-break: break-all;
    }
    .date {
      height: 18px;
      font-size: 12px;
      
      font-weight: 400;
      color: #A8A8A8;
      line-height: 18px;
      margin-bottom: 8px;
      .icon {
        width: 12px;
        height: 12px;
        margin-right: 4px;
        vertical-align: top;
        margin-top: 3px;
      }
    }
    .tags-box {
      overflow: hidden;
      height: 64px;
      .tag {
        height: 24px;
        border-radius: 2px;
        border: 1px solid #D8D8D8;
        line-height: 22px;
        padding: 0 8px;
        font-size: 12px;
        box-sizing: border-box;
        font-weight: 400;
        color: #696969;
        margin-right: 8px;
        margin-bottom: 8px;
        float: left;
      }
    }
  }
}
</style>